//
//  CZDetailTabBar.swift
//  GZWeibo666
//
//  Created by Yuan on 15/12/1.
//  Copyright © 2015年 itcast. All rights reserved.
//

import UIKit
protocol DetailTabBarDelegate : NSObjectProtocol {
    func forwardButtonClickk()
    func commentButtonClickk()
    
}
class CZDetailTabBar: UIView {
    
    //代理属性
    weak var delegate: DetailTabBarDelegate?
    /// 转发按钮
    private lazy var forwardButton: UIButton = {
        let button = UIButton(imageName: "timeline_icon_retweet", title: "转发")
//        button.setImage(UIImage(named: "timeline_icon_retweet"), forState: UIControlState.Normal)
        
        
        button.addTarget(self, action: "forwardButtonClick", forControlEvents: UIControlEvents.TouchUpInside)
        
        return button
    }()
    
    /// 评论按钮
    private lazy var commentButton: UIButton = {
    
        let button = UIButton(imageName: "timeline_icon_comment", title: "评论")
        
        button.addTarget(self, action: "commentButtonClick", forControlEvents: UIControlEvents.TouchUpInside)
        
        return button
    }()
    
    /// 赞按钮
    private lazy var likeButton: UIButton = UIButton(imageName: "timeline_icon_unlike", title: "赞")
    func forwardButtonClick(){
        
        
        delegate?.forwardButtonClickk()
    }
    func commentButtonClick() {
    
       
        delegate?.commentButtonClickk()
    }
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        prepareUI()
    }
    func prepareUI(){
        //设置背景颜色
        backgroundColor = UIColor(white: 0.9, alpha: 1)
        //添加按钮
        addSubview(forwardButton)
        addSubview(commentButton)
        addSubview(likeButton)
        addSubview(sImageViewFirst)
        addSubview(sImageViewSecond)
        
        //约束
        self.ff_HorizontalTile([forwardButton,commentButton,likeButton], insets: UIEdgeInsetsZero)
        //分割线
        sImageViewFirst.ff_AlignHorizontal(type: ff_AlignType.CenterRight, referView: forwardButton, size: nil)
        
        sImageViewSecond.ff_AlignHorizontal(type: ff_AlignType.CenterRight, referView: commentButton, size: nil)
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    /// 分割线1
    private lazy var sImageViewFirst: UIImageView = UIImageView(image: UIImage(named: "timeline_card_bottom_line_highlighted"))
    
    /// 分割线2
    private lazy var sImageViewSecond: UIImageView = UIImageView(image: UIImage(named: "timeline_card_bottom_line_highlighted"))
}
